using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlServerCe;
using FrameworkQ.ObjectSpace.Data.Providers;

namespace FrameworkQ.ObjectSpace
{
	/// <summary>
	/// Creates various types of conenction objects. In future this 
	/// mechanism will be extened to use oracle and access and other
	/// types of database objects.
	/// </summary>
	internal class DBObjectsFactory
	{
        public static IDbConnection CreateConnection(IDatabaseProvider provider, string conenctionString)
        {
            /// TODO : Add other connection support
            // For now we support only sql connection
            IDbConnection conenction = provider.CreateConnection (conenctionString);
            return conenction;
        }

        public static IDbCommand CreateCommand( IDatabaseProvider provider, string commandText, IDbConnection connection,
            IDbTransaction transaction)
        {
            IDbCommand cmd = provider.CreateCommand(connection);
            cmd.CommandText =  commandText;
            if (transaction != null)
            {
                cmd.Transaction = transaction ;
            }
            return (IDbCommand)cmd;
        }

        internal static IDbConnection GetConnection(string connectionString)
        {
            return null;
        }

	}
}
